package com.liuyz;

import java.util.Comparator;
import java.util.TreeSet;

@SuppressWarnings({"all"})
public class TreeSet_ {

    public static void main(String[] args) {
        // TreeSet treeSet = new TreeSet();

        TreeSet treeSet = new TreeSet(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                // 按照长度从大到小进行排序
                return ((String) o2).length() - ((String) o1).length();
            }
        });

        treeSet.add("a");
        treeSet.add("abfasfc");
        treeSet.add("abef");
        treeSet.add("abaff");
        treeSet.add("z");
        System.out.println(treeSet);
    }
}
